package org.finir.fakturisanje.persistence.beans;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import org.finir.fakturisanje.persistence.Preduzece;
import org.finir.fakturisanje.persistence.StavkaFakture;
import org.finir.fakturisanje.persistence.Usluga;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;

@Entity
@Name("usluga")
@Scope(ScopeType.PAGE)
public class UslugaBean implements Usluga, Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Long id;
	private String naziv;
	private Preduzece preduzece;

	@ManyToOne(targetEntity = PreduzeceBean.class)
	public Preduzece getPreduzece() {
		return preduzece;
	}

	public void setPreduzece(Preduzece preduzece) {
		this.preduzece = preduzece;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.a#getId()
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return id;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.a#setId(java.lang.Long)
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.a#getNaziv()
	 */
	public String getNaziv() {
		return naziv;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.a#setNaziv(java.lang.String)
	 */
	public void setNaziv(String naziv) {
		this.naziv = naziv;
	}

	public static long getSerialVersionUID() {
		return serialVersionUID;
	}

	private List<StavkaFakture> stavkeFakture;

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.a#getStavkeFakture()
	 */
	@OneToMany(targetEntity = StavkaFaktureBean.class, cascade = CascadeType.ALL, mappedBy = "usluga")
	public List<StavkaFakture> getStavkeFakture() {
		return stavkeFakture;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	public void setStavkeFakture(List<StavkaFakture> stavkeFakture) {
		this.stavkeFakture = stavkeFakture;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are
		// not set
		if (!(object instanceof UslugaBean)) {
			return false;
		}
		UslugaBean other = (UslugaBean) object;
		if ((this.id == null && other.id != null)
				|| (this.id != null && !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return naziv + " id=" + id;
	}

}
